﻿using UnityEngine;
using System.Collections;
namespace FSM
{
	public class ConditionFactory
	{
		public static T Create<T>(params object[] param) where T:Condition
		{
			T t = ScriptableObject.CreateInstance<T>();
			t.enable = true;
			t.Init(param);
			return t;
		}
		/// <summary>
		/// 创建一个延迟回调逻辑
		/// </summary>
		/// <param name="delay"></param>
		/// <param name="func"></param>
		/// <returns></returns>
		public static IfNode IfNodeDelayCall(float delay,System.Action func)
		{
			var d = ConditionFactory.Create<CDDelay>(delay);
			var call = ConditionFactory.Create<ActionInvoke>(func);
			var ifnode = ConditionFactory.Create<IfNode>(d,call);
			return ifnode;
		}
		/// <summary>
		/// 创建一个延迟动作标准时间的回调逻辑
		/// </summary>
		/// <param name="delay"></param>
		/// <param name="func"></param>
		/// <returns></returns>
		public static IfNode IfNodeDelayClipCall(float delay,System.Action func)
		{
			var d = ConditionFactory.Create<CDDelayClip>(delay);
			var call = ConditionFactory.Create<ActionInvoke>(func);
			var ifnode = ConditionFactory.Create<IfNode>(d,call);
			return ifnode;
		}
	}

}
